package com.dfec.water.dao;

import com.dfec.framework.mybatis.core.mapper.BaseMapperX;
import com.dfec.framework.mybatis.core.page.PageParam;
import com.dfec.framework.mybatis.core.page.PageUtils;
import com.dfec.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.dfec.water.entity.YdbDeviceObserveEntity;
import com.dfec.water.entity.YdbDeviceObserveEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 设备类别Dao接口
 *
 * @author df
 * @date Fri Jan 10 15:02:12 CST 2025
 */
@Mapper
public interface YdbDeviceObserceDao extends BaseMapperX<YdbDeviceObserveEntity> {

    /**
     * description:分页查询
     *
     * @param pageParam 分页参数
     * @return
     * @author trg
     * @date 2023/6/27 15:56
     */
    default PageUtils selectPage(PageParam<YdbDeviceObserveEntity> pageParam) {
        YdbDeviceObserveEntity entity = pageParam.getEntity() == null ? new YdbDeviceObserveEntity() :pageParam.getEntity();
        return this.selectPage(pageParam, dealParams(entity));
    }


    /**
     * 不带分页查询
     * @param ydbDeviceTypeEntity
     * @return
     */
    default  List<YdbDeviceObserveEntity> selectAll(YdbDeviceObserveEntity ydbDeviceTypeEntity){
        return this.selectList(dealParams(ydbDeviceTypeEntity));
    }

    /**
     * description:查询条件拼接
     *
     * @param entity 参数
     * @return
     * @author trg
     * @date 2023/6/27 15:56
     */
    public default LambdaQueryWrapperX<YdbDeviceObserveEntity> dealParams(YdbDeviceObserveEntity entity){
        return new LambdaQueryWrapperX<YdbDeviceObserveEntity>()
                .eqIfPresent(YdbDeviceObserveEntity::getDeviceId, entity.getDeviceId())
                .eqIfPresent(YdbDeviceObserveEntity::getObserveTime, entity.getObserveTime())
                .betweenIfPresent(YdbDeviceObserveEntity::getObserveTime, entity.getDateRange())
                ;
    }




}
